libostree: Variant-related leak plugs and fixes
authorKrzesimir Nowak <krzesimir@kinvolk.io>
Wed, 11 May 2016 09:04:04 +0000 (11:04 +0200)
committerColin Walters (automation) <walters+githubbot@verbum.org>
Thu, 12 May 2016 11:17:09 +0000 (11:17 +0000)
commit862e6ecdcc58f025696b1394adfc0fcf7322df23
tree6ff27b7b6c6fddb237716f8e1790d56287d7ee64
parentaa946cc13636bc45f45f8850e47c456a6019d363
libostree: Variant-related leak plugs and fixes

This tries to avoid leaking GVariantBuilders and GVariants in some
situations. The leaks were usually happening when some error occurred
or because of unclear variant ownership situation.

The former is mostly about making sure that g_variant_builder_clear is
called on builders that didn't finish their variant building process.

The latter is surely more work - sometimes the result of
g_variant_builder_end() should not be passed directly to a function,
but rather stored in a g_autoptr(GVariant), sunk and then passed to a
function. IMO, with an advent of g_autoptr, GVariants should be always
sunk instead of relying on some receiver function sinking it. This
would make an easy-to-follow policy of always sinking your
variants. Functions could then assume that the passed variant is
already sunk. These leaks are still happenning in commands, but they
are less harmful, since that code will not be used by some daemon as a
library routine.

Closes: #291
Approved by: cgwalters
src/libostree/ostree-repo-commit.c
src/libostree/ostree-repo-libarchive.c
src/libostree/ostree-repo-pull.c
src/libostree/ostree-repo-static-delta-compilation.c
src/libostree/ostree-repo.c